package com.shuaigef.springbootinit.model.enums;

import com.shuaigef.springbootinit.exception.BusinessException;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum ExerciseType {
    SINGLE_CHOICE("选择题", 1), // 选择题
    FILL_IN_THE_BLANK("填空题", 2), // 填空题
    DESCRIPTIVE("解答题", 3); // 解答题

    private final String label;
    private final int typeCode;

    public static ExerciseType getExerciseTypeByLabel(String label) {
        for (ExerciseType questionType : ExerciseType.values()) {
            if (questionType.label.equals(label)) {
                return questionType;
            }
        }
        throw new BusinessException(400, "无效的题目类型标签: " + label);
    }
}
